<template>
	<view class="content" :style="'padding-top:'+(contentTopcount+10)+'px'">
		<footer-menu ref="footerMenu" :active="'fuli'" />
		<login v-if="is_login" v-on:x="to_login" v-on:plogin="to_login"></login>
		<view class="title" :style="'top:'+menuTop+';height:'+menuHeight+';'">福利</view>
		<view class="box">
			<view class="banner">
				<swiperList swiperWidth="690rpx" swiperHeight="300rpx" position="3"></swiperList>
			</view>
			<view class="list">
				<view class="item ">
				  <image mode="widthFix" src="https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/play1.png" @click="to(playPage, true)"></image>
				</view>
				<view class="item " v-if="item.is_show" v-for="(item,index) in list">
					<image mode="widthFix" :src="item.img_src" @click="to(item.to_url, item.open)"></image>
				</view>
			</view>
		</view>
	</view>
</template>
<script>
import { imgBasePath } from "@/common/config";
	export default {
		data() {
			return {
				is_to: true,
				is_login: false,
				menuHeight: uni.getStorageSync('menuInfo').menuHeight,
				menuTop: uni.getStorageSync('menuInfo').menuTop,
				contentTopcount:uni.getStorageSync('menuInfo').contentTopcount,
        playPage:"",
				list: [{
						img_src: "https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/icon_yangji.png",
						to_url: "/yangji/index/index",
						is_show: false
					},
					{
						img_src: "https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/img_videodaka2.png",
						to_url: "/pages/VoicePunchIn/VoicePunchIn",
						is_show: false
					},
					{
						img_src: `https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/icon_zhongyi@2x.png`,
						to_url: "/pages/physiqueTest/index?source=1",
						is_show: false,
						open: true,
					},
					{
						img_src: "https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/img_new@2x.png",
						to_url: "/pages/newMember/newMember",
						is_show: false
					},
					{
						img_src: "https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/icon_daka.png",
						to_url: "/videoNote/index/index",
						is_show: true
					},
					{ 
						img_src: "https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/icon_faguanzhe.png",
						to_url: "/pages/fgzhd/huodongbaoming",
						is_show: false
					},
				],
				
			}
		},
		onShow() {
			this.is_to = true
			if (uni.getStorageSync("token")) { //登录判断
				this.is_login = false;
			} else {
				this.is_login = true;
			}
			this.get_play_config()
			this.showSwitch();
			this.inviteActivity()
			this.is_fgzhd()
      let url = 'https://game.renruikeji.cn/shequ/'
      // let url = 'https://game.renruikeji.cn/2048/'
      this.playPage='/pages/webView/webView?url='+url
		},
		methods: {
			//检测活动条装
			is_fgzhd()
			{
				let _this=this;
				let data={
					shopId:uni.getStorageSync("member_info").depId,
				}
				this.$javaJifenApi.doRequest('GET', '/tag/lightShowCustomer/checkJoinLight', data,'json')
				.then(res => { 
					let unionid=uni.getStorageSync("member_info").unionid;
					let url = res.data.data?('/pages/fgzhd/choujiang?canLotteryCount=0'+'&shopId='+data.shopId+"&unionid="+unionid):'/pages/fgzhd/huodongbaoming'
					_this.list[6].to_url=url
				})
			},
			//拉新是否显示检测
			async inviteActivity()
			{
				let {data}=await this.$NoteApi.doRequest('post', 'inviter/inviteActivity', {}, 'json')
				if(data.data.activityEnable==1){
					this.list[3].is_show=true
				}else{
					this.list[3].is_show=false
				}
			},
			showSwitch() {
				this.$request("marketing-tcm/constitution/show-switch", { method: "GET" })
					.then(res => {
						if (res) {
							this.list[2].is_show = true;
						}

					})
					.catch(error => {})
			},
			to(url, open) {
				if (open) {
					uni.navigateTo({
						url: url
					})
					return;
				}
				if (this.is_to) {
					var _this = this;
					_this.is_to = false
					var data = {

					}
					_this.$api.doRequest("post", "api/userinfo", data).then(res => {
						_this.member = res.data.data;
						uni.setStorageSync("member_info", res.data.data);

						if (!res.data.data.user_shopowner_userid) {
							uni.showToast({
								title: "该活动只开放给绑定店长的用户",
								icon: "none"
							})
						} else {
							if(url=="/yangji/index/index"){
								_this.$dadian("toChicken");
							}else if(url=="/pages/VoicePunchIn/VoicePunchIn"){
								_this.$dadian("toVoic");
							}else if(url=="/videoNote/index/index"){
								_this.$dadian("toVideoNote");
							}
							
							uni.navigateTo({
								url: url
							})
						}
					})
				}
			},
			to_login() {
				this.is_login = false
				this.get_play_config()
                this.$refs.footerMenu.getConfig();
			},
			get_play_config() {
				var _this = this;
				_this.$api.doRequest("post", "api/get_game_list2").then(res => {
					// _this.game_bubble_status=res.data.data.game_bubble_status //点点了
					if(res?.data?.data) {
						_this.list[0].is_show = res.data.data.game_chicken_status //养鸡
						_this.list[1].is_show = res.data.data.game_audio_sign_status //语音打卡
					}
				})
			}
		},
	}
</script>

<style scoped>
	.content {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		padding-bottom: 128upx;
		overflow: auto;
		background-image: url(https://wechat-pictures-1301970825.file.myqcloud.com/wxapp/fuli/fuli_bg@2x.png);
		background-repeat: no-repeat;
		background-size: 100% auto;
		height: 100vh;
		box-sizing: border-box;
		padding-top: ;
	}
	.title {
		width: 100%;
		font-size: 30upx;
		color: #fff;
		position: fixed;
		left: 0upx;
		display: flex;
		align-items: center;
		justify-content: center;
		font-size: 36upx;
		font-weight: 500;
		z-index: 10;
	}
	.box{
		flex: 1;
		overflow: auto;
		display: flex;
		flex-direction: column;
		align-items: center;
	}
	.list{
		display: flex;
		justify-content: space-between;
		flex-wrap: wrap;
		box-sizing: border-box;
		padding: 33upx;
	}
	.list .item{
		width: 330upx;
	}
	.list .item image{
		width: 100%;
	}
</style>
